
/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:HistoryTimePresenter.java
 *  项目功能:
 */

/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:ActualTimePresenter.java
 *  项目功能:
 */

/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:DeviceInfoPresenter.java
 *  项目功能:
 */

package com.jg.myproject.presenter;

import com.jg.myproject.api.BaseObserver;
import com.jg.myproject.api.RetrofitFactory;
import com.jg.myproject.api.RxSchedulers;
import com.jg.myproject.api.bean.BaseEntity;
import com.jg.myproject.api.bean.CommonRequestBean;
import com.jg.myproject.api.bean.reponse.CommonReponseBean;
import com.jg.myproject.module.base.IBasePresenter;
import com.jg.myproject.pview.IActualTimeView;

import io.reactivex.Observable;


public class HistoryTimePresenter implements IBasePresenter<CommonRequestBean> {
    private IActualTimeView mIActualTimeView;
    public HistoryTimePresenter(IActualTimeView mIActualTimeView){
        this.mIActualTimeView = mIActualTimeView;
    }

    @Override
    public void getData(CommonRequestBean commonRequestBean) {
        Observable<BaseEntity<CommonReponseBean>> observable = RetrofitFactory.getInstance().monitorDataForGraph(commonRequestBean);
        observable.compose(RxSchedulers.<BaseEntity<CommonReponseBean>>compose(
                mIActualTimeView.<BaseEntity<CommonReponseBean>>bindToLife())).subscribe(new BaseObserver<CommonReponseBean>(mIActualTimeView) {
            @Override
            protected void onHandleSuccess(BaseEntity<CommonReponseBean> bean) {
                mIActualTimeView.getReponseBeans(bean);
            }

            @Override
            protected void onHandleError(BaseEntity<CommonReponseBean> t) {

            }
        });
    }
    public void getData2(CommonRequestBean commonRequestBean) {
        Observable<BaseEntity<CommonReponseBean>> observable = RetrofitFactory.getInstance().monitorData(commonRequestBean);
        observable.compose(RxSchedulers.<BaseEntity<CommonReponseBean>>compose(
                mIActualTimeView.<BaseEntity<CommonReponseBean>>bindToLife())).subscribe(new BaseObserver<CommonReponseBean>(mIActualTimeView) {
            @Override
            protected void onHandleSuccess(BaseEntity<CommonReponseBean> bean) {
                mIActualTimeView.getReponseBeans2(bean);
            }
            @Override
            protected void onHandleError(BaseEntity<CommonReponseBean> t) {
            }
        });
    }
    public void getData3(CommonRequestBean commonRequestBean) {
        Observable<BaseEntity<CommonReponseBean>> observable = RetrofitFactory.getInstance().monitorSectionData(commonRequestBean);
        observable.compose(RxSchedulers.<BaseEntity<CommonReponseBean>>compose(
                mIActualTimeView.<BaseEntity<CommonReponseBean>>bindToLife())).subscribe(new BaseObserver<CommonReponseBean>(mIActualTimeView) {
            @Override
            protected void onHandleSuccess(BaseEntity<CommonReponseBean> bean) {
                mIActualTimeView.getReponseBeans3(bean);
            }
            @Override
            protected void onHandleError(BaseEntity<CommonReponseBean> t) {

            }
        });
    }


}
